IdeaBlade.EntityModel.Compat Assembly > IdeaBlade.EntityModel Namespace > Coroutine Class > StartParallel Method : StartParallel(IEnumerable<Func<INotifyCompleted>>,Action<CoroutineOperation>) Method |
'Declaration
Public Overloads Shared Function StartParallel( _ ByVal asyncFns As IEnumerable(Of Func(Of INotifyCompleted)), _ Optional ByVal completedHandler As Action(Of CoroutineOperation) _ ) As CoroutineOperation
'Usage
Dim asyncFns As IEnumerable(Of Func(Of INotifyCompleted)) Dim completedHandler As Action(Of CoroutineOperation) Dim value As CoroutineOperation value = Coroutine.StartParallel(asyncFns, completedHandler)
public static CoroutineOperation StartParallel( IEnumerable<Func<INotifyCompleted>> asyncFns, Action<CoroutineOperation> completedHandler )
This overload of the StartParallel method is useful in Visual Basic, where iterators are not supported.
public void CoroutineSampleParallel() { // Start some parallel async operations. var op = Coroutine.StartParallel(SampleActions); // Listen for completion. op.Completed += (s, e) => { MessageBox.Show(e.Notifications.Count.ToString() + " operations completed"); // You can loop thru notifications for results from each operation. }; } // A block of asynchronous actions to be performed in parallel. private IEnumerable<INotifyCompleted> SampleActions() { // Start a query for all customers in specified country. yield return _entityManager.Customers.Where(c => c.Country == "UK").ExecuteAsync(); // Start another query for all employees. This will run in parallel. yield return _entityManager.Employees.ExecuteAsync(); } /***************************************************************************************/ // Sample 2 - passing arguments to an iterator public void CoroutineSampleParallel2() { // Start some parallel async operations. var op = Coroutine.StartParallel(() => SampleActions2("UK")); // Listen for completion. op.Completed += (s, e) => { MessageBox.Show(e.Notifications.Count.ToString() + " operations completed"); // You can loop thru notifications for results from each operation. }; } // A block of asynchronous actions to be performed in parallel. private IEnumerable<INotifyCompleted> SampleActions2(string country) { // Start a query for all customers in specified country. yield return _em1.Customers.Where(c => c.Country == country).ExecuteAsync(); // Start another query for all employeesin specified country. This will run in parallel. yield return _em1.Employees.Where(e=> e.Country == country).ExecuteAsync(); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2